﻿@{
    ViewBag.Title = "AddISettingForm";
    Layout = "~/Views/Shared/_Form.cshtml";
}
<script>
    var keyValue = request('keyValue'), _ResponDepts = "";
    $(function () {
        initControl();
    });

    function initControl() {
        //验收种类
        $("#Type").ComboBox({
            url: "../../SystemManage/DataItemDetail/GetDataItemListJson?EnCode=InspectionType",
            id: "ItemValue",
            text: "ItemName",
            description: "==请选择==",
            height: "200px"
        });

        //责任部门
        $("#ResponDepts").ComboBoxTree({
            url: "../../BaseManage/Department/GetTreeJson?organizeId=" + "@LeSoft.Application.Code.OperatorProvider.Provider.Current().CompanyId",
            description: "==请选择==",
            height: "110px",
            click: function (item) {
                if (_ResponDepts != item.id) {
                    _ResponDepts = item.id;
                }
            }
        });

        if (!!keyValue) {
            $.SetForm({
                url: "../../PropertyManage/CS_Inspection/GetEntity",
                param: { keyValue: keyValue },
                success: function (data) {

                    $("#form1").SetWebControls(data);
                    _ResponDepts = data.ResponDepts;
                    $("#Type").ComboBoxSetValue(data.Type);
                    $("#ResponDepts").ComboBoxTreeSetValue(_ResponDepts);
                }
            });
        }
    }


    //保存表单
    function AcceptClick() {
        if (!$('#form1').Validform()) {
            return false;
        }
        var postData = $("#form1").GetWebControls(keyValue);
        postData["Type"] = $("#Type").attr('data-value');
        postData["TypeName"] = $("#Type").attr('data-text');
        postData["ResponDepts"] = _ResponDepts;
        $.SaveForm({
            url: "../../PropertyManage/CS_Inspection/SaveForm?keyValue=" + keyValue,
            param: postData,
            loading: "正在保存数据...",
            success: function () {
                if (top.Form) {
                    top.Form.$("#gridTable").trigger("reloadGrid");
                }
                else
                    $.currentIframe().$("#gridTable").trigger("reloadGrid");
            }
        });
    }
</script>

<div style="margin-left: 10px; margin-top: 20px; margin-right: 30px;">
    <table class="form">
        <tr>
            <td class="formTitle">验收种类</td>
            <td class="formValue">
                <div id="Type" type="selectTree" class="ui-select" isvalid="yes" checkexpession="NotNull"></div>
            </td>
        </tr>
        <tr>
            <td class="formTitle">验收项目名称</td>
            <td class="formValue">
                <input id="Name" type="text" class="form-control" />
            </td>
        </tr>
        <tr>
            <td class="formTitle">验收项目编码</td>
            <td class="formValue">
                <input id="Code" type="text" class="form-control" />
            </td>
        </tr>
        <tr>
            <td class="formTitle">验收标准</td>
            <td class="formValue">
                <input id="Criterion" type="text" class="form-control" />
            </td>
        </tr>
        <tr>
            <td class="formTitle">责任部门</td>
            <td class="formValue">
                <div id="ResponDepts" type="selectTree" class="ui-select" isvalid="yes" checkexpession="NotNull"></div>
            </td>
        </tr>
        <tr>
            <td class="formTitle">选项</td>
            <td class="formValue">
                <div class="checkbox">
                    <label>
                        <input id="EnabledMark" type="checkbox" checked="checked" />
                        有效
                    </label>
                </div>
            </td>
        </tr>
        <tr>
            <td class="formTitle">排序</td>
            <td class="formValue">
                <input id="Sort" type="text" class="form-control" />
            </td>
        </tr>
        <tr>
            <td class="formTitle">附加说明</td>
            <td class="formValue">
                <textarea id="Memo" class="form-control" style="height: 50px;"></textarea>
            </td>
        </tr>
    </table>
</div>
